package com.chenfeng.ego.portal.interceptro;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.chenfeng.ego.commons.util.CookieUtils;

public class CarInterCeptertor implements  HandlerInterceptor
{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		//如果用户没有登录 就跳转到登录页面
		String cook = CookieUtils.getCookieValue(request, "TT_TOKEN");
		if(cook!=null&&cook.equals(""))
		{
			
			return true;
		}
		response.sendRedirect("http://localhost:8084/user/showLogin");
		//如果已经登录就放行
		return false;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception
	{
		// TODO Auto-generated method stub
		
	}

}
